<!DOCTYPE html>
<html>

	<head>
		<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta content="always" name="referrer">
		<meta name="format-detection" content="telephone=no" />
		<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
		<title>找回密码</title>
		<link rel="stylesheet" href="../../css/reset.css">
		<link rel="stylesheet" href="find-password.css">
	</head>

	<body>
		<div class="load-box">
			<div class="phone-box clear">
				<span class="icon-box fl phone-icon"></span>
				<input class="fl phone-input" type="text" name="" placeholder="手机号" />
			</div>
			<div class="verification-box clear">
				<div class="verification-fl fl">
					<span class="icon-box fl verification-icon"></span>
					<input class="fl phone-input" type="text" name="" placeholder="验证码" />
			
				</div>
				<div class="verification-fr fr">
					<input class="fr" id="btnSendCode" type="button" value="发送验证码" onclick="sendMessage()">
				</div>
			</div>
			<div class="password-box clear">
				<span class="icon-box fl p-icon"></span>
				<input class="fl phone-input" type="text" name="" placeholder="登录密码（6-16位数字字母组合）" />
			</div>
			<input type="button" value="我记住了" class="load-btn" />
		</div>
		<script type="text/javascript" src="../../js/flexible.js"></script>
		<script type="text/javascript" src="../../js/jquery-1.11.3.min.js"></script>
		<script>
			var InterValObj; //timer变量，控制时间
			var count = 30; //间隔函数，1秒执行
			var curCount; //当前剩余秒数
			var code = ""; //验证码
			var codeLength = 6; //验证码长度
			function sendMessage() {
				curCount = count;
				var dealType; //验证方式
				var uid = $("#uid").val(); //用户uid
				if($("#phone").attr("checked") == true) {
					dealType = "phone";
				} else {
					dealType = "email";
				}
				//产生验证码
				for(var i = 0; i < codeLength; i++) {
					code += parseInt(Math.random() * 9).toString();
				}
				//设置button效果，开始计时
				$("#btnSendCode").attr("disabled", "true");
				$("#btnSendCode").val(+curCount + "秒再获取");
				InterValObj = window.setInterval(SetRemainTime, 1000); //启动计时器，1秒执行一次
				//向后台发送处理数据
				$.ajax({
					type: "POST", //用POST方式传输
					dataType: "text", //数据格式:JSON
					url: 'Login.ashx', //目标地址
					data: "dealType=" + dealType + "&uid=" + uid + "&code=" + code,
					error: function(XMLHttpRequest, textStatus, errorThrown) {},
					success: function(msg) {}
				});
			}
			//timer处理函数
			function SetRemainTime() {
				if(curCount == 0) {
					window.clearInterval(InterValObj); //停止计时器
					$("#btnSendCode").removeAttr("disabled"); //启用按钮
					$("#btnSendCode").val("重新发送验证码");
					code = ""; //清除验证码。如果不清除，过时间后，输入收到的验证码依然有效    
				} else {
					curCount--;
					$("#btnSendCode").val(+curCount + "秒再获取");
				}
			}
		</script>
	</body>

</html>